Overview

In this Capstone project course, you are going to build REST APIs using Django and Django REST Framework.

In this exercise, you will build a Django project for the Little Lemon restaurant.

Scenario

The owners of the Little Lemon restaurant have hired you to build two APIs. One API to order food using the Menu API . You need to build the Table booking API to facilitate reserving a table for dining in the restaurant on a specific date and for a certain number of people.

Steps

Step 1

If your computer doesn’t already have Python installed on it, download and install from the link: https://www.python.org/downloads/ .

Tip: Make sure to choose the installer for your OS and architecture.

Step 2

You will use VS Code for developing this Capstone project. If not already available locally, install from the link: https://code.visualstudio.com/Download .

Step 3

Create a Python virtual environment, activate it and install Django in it.

python –m venv workspace
cd workspace
scripts\activate
scripts\pip3 install django

Note: The macOS commands to activate virtual environment and install Django

pip install virtualenv
virtualenvmyenv --python=python3
source myenv/bin/activate
pip install django

Step 4

Open VS code from the workspace directory

code .

Step 5

From VS Code extension marketplace, install the Python extension.

Step 6

Press ctrl+shift+p and select Python interpreter. Choose the interpreter in the virtual environment path.

Step 7

Open a new CMD terminal in VS Code. Use the startproject command of django-admin utility.

django-admin startproject littlelemon

Note: If the Powershell terminal opens by default, choose Command Prompt from the drop down

Step 8

Change the current directory to littlelemon and create a djangoapp with the name restaurant .

python manage.py startapp restaurant  

Step 9

Open the settings.py file from the littlelemon project package in a new VS Code window. Add the restaurant app to the INSTALLED_APPS list.

Step 10

From the terminal, start the Django development server with following command:

python manage.py runserver

Tip: It’s safe to ignore the migration related warnings for now.

Step 11

Open the browser window and enter http://localhost:8000/ URL. You should get the page showing the successful installation of Django project.

Conclusion

You have installed Django framework on your computer, and successfully created a Django project.